<?php
namespace Home\Controller;
use Think\Controller;
class TeacherLoginController extends BaseController {


  public function login(){

    $this->display();
}
   
           public function checkLogin(){
        // 丁红苹 检验登录
        session('flag',null);
        //$code=I('post.verify');
        //if(!$this->check_verify($code))$this->error('验证码错误');
        $teacher = M('teacher');
        $map = array();
        $map['teacher_phone'] = I('post.teacher_phone');
        $map['teacher_password'] = I('post.teacher_password');
       
        $res=$teacher->where($map)->select();
        if($res==null){
            $this->error('用户名密码错误');
        }else {
            session("flag","logok");
            dump($_SESSION);
            redirect('count');
        }
    }


    public function _initialize(){
        // 丁红苹 查看是否登录
        header("Content-type:text/html;charset=utf-8");
        if(ACTION_NAME!='login' && ACTION_NAME!='checkLogin'){
            if(null==session('teacher_phone')|| session('flag')!='logok'){
                //redirect('lessonlist');
            }
        }
    }
     public function count(){
        // 崔晓真 统计数据
        if(session('?flag')) {
            $lesson = M('lesson');
            $count1 = $lesson->count();
            $this->count1 = $count1;
            $question = M('question');
            $count2 = $question->count();
            $this->count2 = $count2;
           
            $this->display();
            } 
        else {
            echo'没有登录';
        }
     }

  }
    
?>


